{include file="public/header"}
<link rel="stylesheet" type="text/css" href="__ADMIN__css/login1.css">
<script type="text/javascript" src="__ADMIN__js/login1.js"></script>
<script type="text/javascript" src="__ADMIN__layui/sliderVerify.js"></script>
</head>
<style>
    .slider-item {
        height: 44px;
        line-height: 44px;
    }
</style>

<body>
    <div class="loginBg">
    </div>
    <div class="login_main">
        <div class="box">
            <div class="left">
                <img src="__ADMIN__images/logo.png" />
                <p>后台系统</p>
            </div>
            <div class="right">
                <form class="layui-form layui-form-pane">
                    <div class="layui-form-item">
                        <label class="layui-form-label login_title"><i
                                class="iconfont icon-gerenzhongxin-denglu"></i></label>
                        <div class="layui-input-block login_input">
                            <input type="text" name="username" required lay-verify="required" autocomplete="off"
                                placeholder="请输入您的用户名" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label login_title"><i class="iconfont icon-mima1"></i></label>
                        <div class="layui-input-block login_input">
                            <input type="password" name="password" required lay-verify="required" autocomplete="off"
                                placeholder="请输入密码" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label login_title"><i class="iconfont icon-duigou"></i></label>
                        <div class="layui-input-block login_input">
                            <div id="slider"></div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <button class="layui-btn layui-btn-fluid login_but" lay-submit lay-filter="loginBut">登
                            录</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script type="text/javascript" charset="utf-8">
        if (self != top) {
            parent.location.reload();
        }
        layui.config({
            base: '/static/admin/layui/'
        }).use(['sliderVerify', 'jquery', 'form', 'layer'], function () {
            var sliderVerify = layui.sliderVerify,
                $ = layui.jquery,
                form = layui.form;
            var layer = layui.layer;
            var slider = sliderVerify.render({
                elem: '#slider',
            });
            //监听提交
            form.on('submit(loginBut)', function (data) {
                if (slider.isOk()) {
                    // console.log(slider.isOk());
                    // layer.msg(JSON.stringify(data.field));
                    $.ajax({
                        url:'{:url("login/login")}',
                        data: data.field,
                        type: 'POST',
                        dataType: 'Json',
                        success: function (res) {
                            // console.log(res);
                            if (res.code == 100) {
                                verify(res.val.name, res.val.msg);
                            } else if (res.code == 0) {
                                $(window).attr('location', '{:url("Index/index")}');
                            } else {
                                layer.msg(res.msg, {
                                    icon: 2
                                });
                                slider.reset();
                            }
                        }, error: function () {
                            layer.msg('网络出错，请联系管理员!', {
                                icon: 0
                            });
                            slider.reset();
                        }
                    });
                } else {
                    layer.msg("请先通过滑块验证");
                }
                return false;
            });
        })
    </script>
</body>
{include file="public/footer"}